package com.dqhl.community.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dqhl.community.R;
import com.dqhl.community.base.BaseActivity;

/**
 * Created by guanlucoang on 2016/8/30.
 * 物业缴费 activity
 */
public class PropertyPayActivity extends BaseActivity implements View.OnClickListener {

    private ImageView ivTopBack;
    private TextView tvTopTitle;
    private ImageView ivPayProperty; //物业费
    private ImageView ivPayWater; //水费
    private ImageView ivPayElectric; //电费
    private ImageView ivPayClean; //卫生费
    private ImageView ivPayGas; //燃气费
    private ImageView ivPayElevator; //电梯费
    private String propertyType = "0"; //缴费类型
    private Bundle bundle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_property_pay);
        bundle = new Bundle();
        // 实例化对象
        initView();
        // 实例化数据
        initListener();
    }

    /**
     * 实例化对象
     */
    private void initView() {
        ivTopBack = (ImageView) findViewById(R.id.iv_top_back);
        tvTopTitle = (TextView) findViewById(R.id.tv_top_title);

        ivPayProperty = (ImageView) findViewById(R.id.iv_pay_property);
        ivPayWater = (ImageView) findViewById(R.id.iv_pay_water);
        ivPayElectric = (ImageView) findViewById(R.id.iv_pay_electric);
        ivPayClean = (ImageView) findViewById(R.id.iv_pay_clean);
        ivPayGas = (ImageView) findViewById(R.id.iv_pay_gas);
        ivPayElevator = (ImageView) findViewById(R.id.iv_pay_elevator);
    }

    /**
     * 设置控件监听事件
     */
    private void initListener() {
        ivTopBack.setVisibility(View.VISIBLE);
        ivTopBack.setOnClickListener(this);
        tvTopTitle.setText(R.string.propertyPay);

        ivPayProperty.setOnClickListener(this);
        ivPayWater.setOnClickListener(this);
        ivPayElectric.setOnClickListener(this);
        ivPayClean.setOnClickListener(this);
        ivPayGas.setOnClickListener(this);
        ivPayElevator.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_top_back:
                finish();
                break;
            case R.id.iv_pay_property: //跳转到缴纳物业费页面
                propertyType = "1";
                Bundle bundle_property = new Bundle();
                bundle_property.putString("type", propertyType);
                overlay(PropertyRentalActivity.class, bundle_property);
                break;
            case R.id.iv_pay_water: //水费
                propertyType = "2";
                bundle.putString("type", propertyType);
                overlay(PropertyRentalActivity.class, bundle);
                break;
            case R.id.iv_pay_electric: //电费
                propertyType = "3";
                bundle.putString("type", propertyType);
                overlay(PropertyRentalActivity.class, bundle);
                break;
            case R.id.iv_pay_clean: //卫生费
                propertyType = "4";
                bundle.putString("type", propertyType);
                overlay(PropertyRentalActivity.class, bundle);
                break;
            case R.id.iv_pay_gas: //燃气费
                propertyType = "5";
                bundle.putString("type", propertyType);
                overlay(PropertyRentalActivity.class, bundle);
                break;
            case R.id.iv_pay_elevator: //电梯费
                propertyType = "6";
                bundle.putString("type", propertyType);
                overlay(PropertyRentalActivity.class, bundle);
                break;
        }
    }
}
